package com.yhy.manager.controller;

import com.yhy.manager.service.ManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/manage")
public class ManageController {

    @Autowired
    private ManagerService managerService;

    /**
     * 用户数据翻页
     *
     * 接口路径：GET/manage/users
     *
     *
     * 请求参数: Query:
     *      page: 页数
     *      pagesize: 页尺寸
     *
     *返回值: PageResult<UserInfo>
     */
    @GetMapping("/users")
    public ResponseEntity userPage(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer pagesize){
        return managerService.userPage(page,pagesize);
    }

    /**
     * 用户基本资料
     *
     * 接口路径：GET/manage/users/:userId
     *
     * 请求参数:
     *      userId: 用户id
     *
     * 返回值:
     */
    @GetMapping("/users/{userId}")
    public ResponseEntity userDetail(@PathVariable("userId") Long userId){
        return managerService.userDetail(userId);
    }

    /**
     * 视频记录翻页
     *
     * 接口路径：GET/manage/videos
     *
     * 请求参数: Query
     *      page: 页数
     *      pagesize: 页尺寸
     *      uid: 用户id
     *
     * 返回值: PageResult<VideoVo>
     */
    @GetMapping("/videos")
    public ResponseEntity videos(@RequestParam(defaultValue = "1") Integer page,
                                 @RequestParam(defaultValue = "10") Integer pagesize,
                                 Long uid){
        return managerService.findVideosByUid(page,pagesize,uid);
    }

    /**
     * 动态分页
     *
     * 接口路径：GET/manage/messages
     *
     * 请求参数: Query
     *      page: 页数
     *      pagesize: 页尺寸
     *      uid: 用户id
     *      state: 审核状态
     *
     * 返回值: PageResult<Movements>(Publish的vo)
     */
    @GetMapping("/messages")
    public ResponseEntity messages(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer pagesize,
                                   Long uid,Integer state){
        return managerService.findAllMovements(page,pagesize,uid,state);
    }

    /**
     * 动态详情
     *
     * 接口路径：GET/manage/messages/:id
     *
     * 请求参数:
     *      id: 消息id
     *
     * 返回值:
     */
    @GetMapping("/messages/{id}")
    public ResponseEntity publishDetail(@PathVariable("id") String publishId){
        return managerService.publishDetail(publishId);
    }

    /**
     * 评论列表翻页
     *
     * 接口路径：GET/manage/messages/comments
     *
     * 请求参数: Query
     *      page: 页数
     *      pagesize: 页尺寸
     *      messageID: 消息id
     *
     */
    @GetMapping("/messages/comments")
    public ResponseEntity comments(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "10") Integer pagesize,
                                   String messageID){
        return managerService.findAllComments(page,pagesize,messageID);
    }
}
